<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的购物车-小米商城</title>
<script src="js/jquery-3.3.1.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="./css/style.css">
</head>
<body>
	<!-- start header -->
	<!--end header -->

	<!-- start banner_x -->
	<div class="banner_x center">
		<a href="./index.html" target="_self"><div class="logo fl"></div></a>

		<div class="wdgwc fl ml40">我的购物车</div>
		<div class="wxts fl ml20">温馨提示：产品是否购买成功，以最终下单为准哦，请尽快结算</div>
		<div class="dlzc fr">
			<ul>
				<li>
							<c:if test="${user != null }">
								<a href="${ctx}/selfInfo" target="_blank">${user.uname }</a>
							</c:if>
							<c:if test="${user == null }">
								<a href="./login.html" target="_blank">登录</a>
							</c:if>
							</li>
				<li>|</li>
				<li><a href="./register.html" target="_blank">注册</a></li>
			</ul>

		</div>
		<div class="clear"></div>
	</div>
	<div class="xiantiao"></div>
	<div class="gwcxqbj">
		<div class="gwcxd center">
			<div class="top2 center">
				<div class="sub_top fl">
					<!-- <input type="checkbox" value="quanxuan" class="quanxuan" />全选 -->
				</div>
				<div class="sub_top fl">商品名称</div>
				<div class="sub_top fl">单价</div>
				<div class="sub_top fl">数量</div>
				<div class="sub_top fl">小计</div>
				<div class="sub_top fr">操作</div>
				<div class="clear"></div>
			</div>
			<c:forEach var="gouwuche" items="${list}">
				<tr>
					<div class="content2 center">
						<div class="sub_content fl ">
							<c:if test="${gouwuche.sel == 1}">
								<input id="a${gouwuche.catid}" type="checkbox" checked
									value="quanxuan" class="quanxuan"
									onclick="fun1(${gouwuche.catid})" />
							</c:if>
							<c:if test="${gouwuche.sel == 0}">
								<input id="a${gouwuche.catid}" type="checkbox" value="quanxuan"
									class="quanxuan" onclick="fun1(${gouwuche.catid})" />
							</c:if>

						</div>
						<div class="sub_content fl">
							<img src="./image/gwc_xiaomi6.jpg">
						</div>
						<div class="sub_content fl ft20" style="width:250px">${gouwuche.goods_name}</div>
						<div class="sub_content fl ">${gouwuche.cash}元</div>
						<div class="sub_content fl">
							<input id="b${gouwuche.catid}" class="shuliang" type="number" value="${gouwuche.num}"
								step="1" min="1" onchange="fun2(${gouwuche.catid})">
						</div>
						<div class="sub_content fl" style="width:90px">${gouwuche.cash*gouwuche.num}元</div>
						<div class="sub_content fl">
							<a href="DeleteFormGouWuCheServlet?catid=${gouwuche.catid}">×</a>
						</div>

					</div>
					<div class="clear"></div>
				</tr>
			</c:forEach>
		</div>

		<div class="clear"></div>

		<div class="jiesuandan mt20 center">
			<div class="tishi fl ml20">
				<ul>
					<li><a href="./liebiao.html">继续购物</a></li>
					<li>|</li>
					<li><span></span><span></span>
					</li>
					<div class="clear"></div>
				</ul>
			</div>
			<div class="jiesuan fr">
				<div class="jiesuanjiage fl">
					<span></span>
				</div>
				<div class="jsanniu fr">
					<input class="jsan" type="submit" name="jiesuan" value="去结算" />
				</div>
				<div class="clear"></div>
			</div>
			<div class="clear"></div>

		</div>

	</div>

	<div class="clear"></div>


	<!-- footer -->
	<footer class="center">

		<div class="mt20">小米商城|MIUI|米聊|多看书城|小米路由器|视频电话|小米天猫店|小米淘宝直营店|小米网盟|小米移动|隐私政策|Select
			Region</div>
		<div>©mi.com 京ICP证110507号 京ICP备10046444号 京公网安备11010802020134号
			京网文[2014]0059-0009号</div>
		<div>违法和不良信息举报电话：185-0130-1238，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</div>
	</footer>
	<%-- <c:forEach var="gouwuche" items="${list}">
		<h1>${gouwuche.goods_name}</h1>
	</c:forEach> --%>
</body>

<script type="text/javascript">

function fun1(catid){

	var catid1 = "#a"+catid;
 if($(catid1).is(':checked'))
	{
	 var sel = 1;
	}else
	{
	 var sel = 0;
	} 
 /* alert($(catid1).is(':checked')); 
	alert(catid1);  */
	  $.ajax({
		type : 'POST',
		url : 'ChangeSelFormGouWuCheServlet',
		data:{
                "catid":catid,
                "sel":sel
           },
           async:true,
           success:function(d){
                alert("success");
           },
		error : function(xhr, errorText, errorStatus) {
			alert("error");
		} 
	}); 
	
}
function fun2(catid){

	var catid1 = "b"+catid;	
	var num = document.getElementById(catid1).value;
	  $.ajax({
			type : 'POST',
			url : 'ChangeNumFormGouWuCheServlet',
			data:{
	                "catid":catid,
	                "num":num
	           },
	           async:true,
	           success:function(d){
	                alert("success");
	           },
			error : function(xhr, errorText, errorStatus) {
				alert("error");
			} 
		}); 
	
	
}

</script>
</html>

